/*
 * @lc app=leetcode.cn id=1957 lang=javascript
 *
 * [1957] 删除字符使字符串变好
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var makeFancyString = function (s) {
  let cur = 1;
  let res = s[0];
  for (let i = 1; i < s.length; i++) {
    if (s[i] === s[i - 1]) {
      cur++;
      if (cur <= 2) {
        res += s[i];
      }
    } else {
      cur = 1;
      res += s[i];
    }
  }
  return res;
};
// @lc code=end

